const {
    SyncHook,
    SyncBailHook,
    SyncWaterfallHook,
    SyncLoopHook,
    AsyncParallelHook,
    AsyncParallelBailHook,
    AsyncSeriesHook,
    AsyncSeriesBailHook,
    AsyncSeriesWaterfallHook
} = require('tapable');

const hook = new AsyncSeriesBailHook(['name', 'age']);
console.log('start');
/*hook.tapPromise('event1', (name, age) => {
    console.log('event1', name, age);
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            resolve(1);
        }, 1000);
    });
});
hook.tapPromise('event2', (name, age) => {
    console.log('event2', name, age);
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            resolve(2);
        }, 2000);
    });
});
hook.tapPromise('event3', (name, age) => {
    console.log('event3', name, age);
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            resolve(3);
        }, 3000);
    });
});
hook.promise('zhang', 19).then((res) => {
    console.log('res', res);
}, (err) => {
    console.log('err', err);
});*/

hook.tapAsync('event1', (name, age, cb) => {
    console.log('event1', name, age);
    setTimeout(() => {
        cb(null,1,1);
    }, 1000);
});
hook.tapAsync('event2', (name, age, cb) => {
    console.log('event2', name, age);
    setTimeout(() => {
        cb(null,2,2);
    }, 2000);
});
hook.tapAsync('event3', (name, age, cb) => {
    console.log('event3', name, age);
    setTimeout(() => {
        cb(null,3,3);
    }, 3000);
});
hook.callAsync('zhang', 19, (err, res) => {
    console.log('res', res);
    console.log('err', err);
});
console.log('end');